package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Material;
import com.ruoyi.system.domain.MaterialSeven;
import com.ruoyi.system.service.IMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 材料占仓来源明细Controller
 * 
 * @author ruoyi
 * @date 2020-12-17
 */
@RestController
@RequestMapping("/system/materialdetails")
public class MaterialdetailsController extends BaseController
{

    @Autowired
    private IMaterialService materialService;

    /**
     * 查询项目单材料列表
     */
    @PostMapping("/list")
    public TableDataInfo listQuery(Material material, Integer pid, Integer mid)
    {
        startPage();
        List<MaterialSeven> list = materialService.selectmaterialdetailsList(material,pid,mid);

        return getDataTable(list);
    }
    /**
     * 查询项目单材料记录列表
     */
    @PostMapping("/record/list")
    public TableDataInfo list(Material material, Integer pid, Integer mid)
    {
        startPage();
        List<Material> list = materialService.selectmaterialRecordList(material,pid,mid);
        return getDataTable(list);
    }
    /**
     * 导出材料列表
     */
//    @RequiresPermissions("system:material:export")
    @Log(title = "材料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public AjaxResult export(Material material, Integer pid, Integer mid)
    {
        List<MaterialSeven> list = materialService.selectmaterialdetailsList(material,pid,mid);
        ExcelUtil<MaterialSeven> util = new ExcelUtil<MaterialSeven>(MaterialSeven.class);
        return util.exportExcel(list, "material");
    }

}
